<?xml version="1.0" encoding="UTF-8"?>

<xsl:stylesheet
	version="1.0"
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
	xmlns:php="http://php.net/xsl">	
	
	<xsl:include href="../main.xsl" />
	<xsl:include href="menu.xsl" />
	<xsl:include href="../common/navigation.xsl" />

	<xsl:template match="/data">
		<html>
		
		<head>
			<title>
				<xsl:value-of select="$pageTitle" />
			</title>
			<xsl:call-template name="meta-head" />
			<link rel="stylesheet" href="{$baseURI}/css/micro/micro.css" type="text/css" media="all" />
		</head>
		<body>
			
			<xsl:call-template name="top-userbar" />

			<div class="page-header">
				<xsl:call-template name="logo" />

				<xsl:call-template name="menu" />
			</div>

			<div class="page-content-wrapper">
				<div class="page-blocks">
					<xsl:call-template name="default-blocks-top" />
					
					<div class="block">
						<div class="header">Метки</div>
						<div class="content tags">
							<xsl:apply-templates select="document('xmodule://micro/getTagsCloud')/data/response" mode="block-tags-cloud" />
						</div>
						
						<i class="corner-f8-10 tl"></i>
						<i class="corner-f8-10 tr"></i>
						<i class="corner-f8-10 br"></i>
						<i class="corner-f8-10 bl"></i>
					</div>
				</div>
	
				<div class="page-content">
					<xsl:apply-templates select="response" />
				</div>
			</div>

			<xsl:call-template name="footer" />
		</body>
		</html>
	</xsl:template>
	
	
	<xsl:template match="response">
		<xsl:param name="cnt" select="count(object)" />
		
		<h1>Микро</h1>
		
		<div class="micro-list">
			<xsl:apply-templates select="object[@type='micro']" />
		</div>
		
		<xsl:apply-templates select="pages" mode="pages-navigation">
			<xsl:with-param name="href">
				<xsl:value-of select="$baseURI" />
				<xsl:text>/micro</xsl:text>
			</xsl:with-param>
		</xsl:apply-templates>
	</xsl:template>
	
	<xsl:template match="object[@type='micro']">
		<xsl:param name="userLogin" select="property[@name='user_login']/value" />
		<xsl:param name="userAvatar" select="property[@name='user_avatar']/value" />
		
		<div class="item">
			<div class="avatar">
				<a href="{$baseURI}/user/{$userLogin}">
					<xsl:if test="$userAvatar = ''">
						<img src="{$baseURI}/images/default-user-avatar.png" alt="{$userLogin}" />
					</xsl:if>
					<xsl:if test="$userAvatar != ''">
						<img src="{$baseURI}/thumb_50_50{$userAvatar}" alt="{$userLogin}" />
					</xsl:if>
				</a>
			</div>
			
			<div class="body">
				<div class="header">
					<span class="date">
						<xsl:value-of select="property[@name='pubdate']/value" />
					</span>
					
					<a href="{$baseURI}/user/{$userLogin}">
						<xsl:value-of select="$userLogin" />
					</a>
				</div>
				
				<div class="content">
					<xsl:value-of select="php:functionString ('XSLTParseMicroTags', property[@name='text']/value, concat($baseURI, '/micro/tag/'))" disable-output-escaping="yes" />
				</div>
			</div>
		</div>
	</xsl:template>
	
	<!-- TAGS CLOUD -->
	<xsl:template match="tags" mode="block-tags-cloud">
		<xsl:for-each select="tag">
			<a>
				<xsl:attribute name="href">
					<xsl:value-of select="concat ($baseURI, '/micro/tag/', value)" />
				</xsl:attribute>
				<xsl:attribute name="style">
					<xsl:value-of select="concat ('font-size: ', size, 'px')" />
				</xsl:attribute>
				<xsl:value-of select="value" />
			</a>
			<xsl:text> </xsl:text>
		</xsl:for-each>
	</xsl:template>
	
</xsl:stylesheet>